package com.com.ruandi.test15;

//圆形类
public class Circle extends Graphic{
    private double r;

    public Circle() {
    }

    public Circle(double r) {
        this.r = r;
    }

    public double getR() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    @Override
    public String toString() {
        return "圆形\n" +
                "半径为：" + r
                +"\n";
    }

    //面积方法
    @Override
    public double getArea() {
        return r*r*Math.PI;
    }

    //周长方法
    @Override
    public double getPerimeter() {
        return 2*r*Math.PI;
    }

    @Override
    public String showInfo() {
        return "圆形";
    }
}
